<?php

	/**
	 * Workspace@ Engine application comment!
	 * 
	 * LICENSE
	 * This application is licensed under New BSD license.
	 * Please read complete LICENSE.txt inside of root folder for more details.
	 * 
	 * We wish you good building :) 
	 * 
	 * @category   Application
	 * @package    Bootstrap
	 * @author     Nevio Vesic <nevio@workspaceat.com>
	 * @copyright  2008-2009 Workspace@ group in association with Design strategist
	 */


	# lets load global configuration files
	# and engine a.k.a lets set include path :D
	ini_set ( "include_path", get_include_path() . PATH_SEPARATOR . ".conf/" . PATH_SEPARATOR . "library/" );
	
	# ok lets call exception manager
	require_once "Application/Exception.php";
	
	# ok now we need to load checkings... a.k.a find out if current url is frontend or backend
	require_once "Zend/Config.php";
	require_once 'Zend/Config/Ini.php';
	require_once "Application/Locator.php";
	
	# lets setup base application locations
	$data = new Zend_Config ( array (
	
		"backend" => array (
			"url" => "http://{$_SERVER['HTTP_HOST']}/",
			"accessuri" => "engine/backend",
		),
		
		"frontend" => array (
			"url"  => "http://{$_SERVER['HTTP_HOST']}/",
			"accessuri" => "engine",
		),
		
	), true);
	
	$locator = new Engine_Application_Locator( $data );
	$locator -> analyzeLocation();

	# lets load and initialize application configuration
	# As well add current application name... THIS IS IMPORTANT!
	# We need somehow to allocate which application config dir to locate...
	require_once "Application/Configuration.php";
	
	$conf  = Engine_Application_Configuration::factory( "engine" );
	require_once Engine_Application_Configuration::loadDatabase();
	
	# lets load application
	require_once "Application.php";
	
	$app = new Engine_Application( $data );
	$app -> throwErrors( true );
	$app -> run(); 
